

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>l5kit.sampling.agent_sampling module &mdash; L5Kit 1.0.0 documentation</title>
  

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />

  
  
  
  

  
  <!--[if lt IE 9]>
    <script src="../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="l5kit.sampling.slicing module" href="l5kit.sampling.slicing.html" />
    <link rel="prev" title="l5kit.sampling package" href="l5kit.sampling.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html" class="icon icon-home" alt="Documentation Home"> L5Kit
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../README.html">ML Prediction, Planning and Simulation for Self-Driving</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#examples">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#news">News</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#overview">Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#installation">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#license">License</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#credits">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="../README.html#contact">Contact</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../api_reference.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="l5kit.data.html">l5kit.data package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.dataset.html">l5kit.dataset package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.evaluation.html">l5kit.evaluation package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.geometry.html">l5kit.geometry package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.kinematic.html">l5kit.kinematic package</a></li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.random.html">l5kit.random package</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="l5kit.sampling.html">l5kit.sampling package</a><ul class="current">
<li class="toctree-l3 current"><a class="reference internal" href="l5kit.sampling.html#submodules">Submodules</a><ul class="current">
<li class="toctree-l4 current"><a class="current reference internal" href="#">l5kit.sampling.agent_sampling module</a></li>
<li class="toctree-l4"><a class="reference internal" href="l5kit.sampling.slicing.html">l5kit.sampling.slicing module</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="l5kit.visualization.html">l5kit.visualization package</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../data_format.html">Dataset Formats</a></li>
<li class="toctree-l1"><a class="reference internal" href="../how_to_contribute.html">How to contribute</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">L5Kit</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../api_reference.html">API Reference</a> &raquo;</li>
        
          <li><a href="l5kit.sampling.html">l5kit.sampling package</a> &raquo;</li>
        
      <li>l5kit.sampling.agent_sampling module</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/API/l5kit.sampling.agent_sampling.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-l5kit.sampling.agent_sampling">
<span id="l5kit-sampling-agent-sampling-module"></span><h1>l5kit.sampling.agent_sampling module<a class="headerlink" href="#module-l5kit.sampling.agent_sampling" title="Permalink to this headline">¶</a></h1>
<dl class="py function">
<dt id="l5kit.sampling.agent_sampling.generate_agent_sample">
<code class="sig-prename descclassname">l5kit.sampling.agent_sampling.</code><code class="sig-name descname">generate_agent_sample</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">state_index</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">frames</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">all_agents</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">selected_track_id</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span>int<span class="p">]</span></span></em>, <em class="sig-param"><span class="n">raster_size</span><span class="p">:</span> <span class="n">Tuple<span class="p">[</span>int<span class="p">, </span>int<span class="p">]</span></span></em>, <em class="sig-param"><span class="n">pixel_size</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">ego_center</span><span class="p">:</span> <span class="n">numpy.ndarray</span></em>, <em class="sig-param"><span class="n">history_num_frames</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">history_step_size</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">future_num_frames</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">future_step_size</span><span class="p">:</span> <span class="n">int</span></em>, <em class="sig-param"><span class="n">filter_agents_threshold</span><span class="p">:</span> <span class="n">float</span></em>, <em class="sig-param"><span class="n">rasterizer</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="l5kit.rasterization.rasterizer.html#l5kit.rasterization.rasterizer.Rasterizer" title="l5kit.rasterization.rasterizer.Rasterizer">l5kit.rasterization.rasterizer.Rasterizer</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em>, <em class="sig-param"><span class="n">perturbation</span><span class="p">:</span> <span class="n">Optional<span class="p">[</span><a class="reference internal" href="l5kit.kinematic.perturbation.html#l5kit.kinematic.perturbation.Perturbation" title="l5kit.kinematic.perturbation.Perturbation">l5kit.kinematic.perturbation.Perturbation</a><span class="p">]</span></span> <span class="o">=</span> <span class="default_value">None</span></em><span class="sig-paren">)</span> &#x2192; dict<a class="headerlink" href="#l5kit.sampling.agent_sampling.generate_agent_sample" title="Permalink to this definition">¶</a></dt>
<dd><dl>
<dt>Generates the inputs and targets to train a deep prediction model. A deep prediction model takes as input</dt><dd><p>the state of the world (here: an image we will call the “raster”), and outputs where that agent will be some
seconds into the future.</p>
<p>This function has a lot of arguments and is intended for internal use, you should try to use higher level classes
and partials that use this function.</p>
<dl>
<dt>Arguments:</dt><dd><p>state_index {int} – The anchor frame index, i.e. the “current” timestep
frames {np.ndarray} – The whole frames array, can be numpy array or a zarr array.
all_agents {np.ndarray} – The whole agents array, can be numpy array or a zarr array.
selected_track_id: {Optional[int]} – Either None for AV, or the ID of an agent that you want to
predict the future of. This agent is centered in the raster and the returned targets are derived from
their future states.
raster_size {Tuple[int, int]} – Desired output raster dimensions
pixel_size {np.ndarray} – Size of one pixel in the real world
ego_center {np.ndarray} – Where in the raster to draw the ego, [0.5,0.5] would be the center
history_num_states {int} – Amount of history frames to draw into the rasters.,
history_step_size {int} – Steps to take between frames, can be used to subsample history frames.
future_num_states {int} – Amount of history frames to draw into the rasters.
future_step_size {int} – Steps to take between targets into the future.
filter_agents_threshold {float} – Value between 0 and 1 to use as cutoff value for agent filtering
based on their probability of being a relevant agent.
rasterizer {Rasterizer} – Rasterizer of some sort that draws a map image.</p>
<p>voxel_shape (Tuple[int, int]): Desired output raster dimensions
voxel_size (np.ndarray): Size of one pixel in the real world
voxel_ego_center (np.ndarray): Where in the raster to draw the ego, [0.5,0.5] would be the center
history_num_states (int): Amount of history frames to draw into the rasters.,
history_step_size (int): Steps to take between frames, can be used to subsample history frames.
future_num_states (int): Amount of history frames to draw into the rasters.
future_step_size (int): Steps to take between targets into the future.
filter_agents_threshold (float): Value between 0 and 1 to use as cutoff value for agent filtering</p>
</dd>
</dl>
</dd>
</dl>
<p>based on their probability of being a relevant agent.</p>
<blockquote>
<div><dl class="simple">
<dt>Keyword Arguments:</dt><dd><p>rasterizer (Optional[Rasterizer]): Rasterizer of some sort that draws a map image.
perturbation (Optional[Perturbation]): Object that perturbs the input and targets, used</p>
</dd>
</dl>
</div></blockquote>
<p>to train models that can recover from slight divergence from training set data (default: {None})</p>
<blockquote>
<div><dl class="simple">
<dt>Raises:</dt><dd><p>ValueError: A ValueError is returned if the specified <code class="docutils literal notranslate"><span class="pre">selected_track_id</span></code> is not present in the scene
or was filtered by applying the <code class="docutils literal notranslate"><span class="pre">filter_agent_threshold</span></code> probability filtering.</p>
</dd>
<dt>Returns:</dt><dd><p>input_im (np.ndarray): Input raster to be used as input of a learned prediction or planning model.
future_coords_offset (np.ndarray): The offset from the current state in terms of translation, currently</p>
</dd>
</dl>
</div></blockquote>
<p>expressed in pixels (to be changed).</p>
<blockquote>
<div><p>future_yaws_offset (np.ndarray): The yaw offset of future frames from the current frame.
future_availability (np.ndarray): A binary mask of <code class="docutils literal notranslate"><span class="pre">future_num_states</span></code> length whether there is a valid
target for that state. If you sample near the end of a scene, this may contain zeroes.</p>
</div></blockquote>
</dd></dl>

</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="l5kit.sampling.slicing.html" class="btn btn-neutral float-right" title="l5kit.sampling.slicing module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="l5kit.sampling.html" class="btn btn-neutral float-left" title="l5kit.sampling package" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        
        &copy; Copyright 2020, Lyft Level 5

    </p>
  </div>
    
    
    
    Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
    
    <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
    
    provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>